﻿<?php
require_once("../../class2.php");
require_once("./includes/require_all.php");

$catgame= mysql_real_escape_string($_GET['cg']);
$pref= $catgame;//mysql_fetch_array(mysql_query("SELECT Prefix FROM gcs_main WHERE Game='$catgame'"));
$gamecolumn= 'g'.$pref;
$mygame= mysql_query("SELECT UserNAME,UserID,$gamecolumn FROM gcs_mygames WHERE $gamecolumn!='0'");

$willplay=0;$nowplay=0;$hasplay=0;$unplay=0;
while ($mg= mysql_fetch_array($mygame)) {
	switch($mg[$gamecolumn]) {
		case '1': $willplay++; $str_wp.= "<a href='http://playonbg.info/user.php?id.$mg[UserID]' class='forumheader'>".$mg['UserNAME']."</a> * "; break;
		case '2': $nowplay++; $str_np.= "<a href='http://playonbg.info/user.php?id.$mg[UserID]' class='forumheader'>".$mg['UserNAME']."</a> * "; break;
		case '3': $hasplay++; $str_hp.= "<a href='http://playonbg.info/user.php?id.$mg[UserID]' class='forumheader'>".$mg['UserNAME']."</a> * "; break;
		case '4': $unplay++; $str_up.= "<a href='http://playonbg.info/user.php?id.$mg[UserID]' class='forumheader'>".$mg['UserNAME']."</a> * "; break;
	}
}

echo "<div id='result'>
		<div class='forumheader3'> Ще играят($willplay)</div>
		<div class='forumheader'>$str_wp</div>
		<div class='forumheader3'> Сега играят($nowplay)</div>
		<div class='forumheader'>$str_np</div>
		<div class='forumheader3'> Изиграли($hasplay)</div>
		<div class='forumheader'>$str_hp</div>
		<div class='forumheader3'> Недоиграли($unplay)</div>
		<div class='forumheader'>$str_up</div>
		<div class='forumheader3'></div>
	</div>";
	
mysql_query("UPDATE gcs_main SET stWP='$willplay',stNP='$nowplay',stHP='$hasplay',stUP='$unplay' WHERE prefix='$catgame'");
?>